package com.baixun.gasadmin.controller;

import com.baixun.gasentity.dto.AlgorithmCallbackRequest;
import com.baixun.gassystem.service.AlgorithmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @program: 上海燃气驾驶舱
 * @description: 数据回调接口
 * @author: yesong
 **/
@Api(tags = "数据回调接口")
@RestController
@RequestMapping("/api/callback")
public class AlgorithmCallbackController {

    private final AlgorithmService algorithmService;

    // 构造器注入 AlgorithmService
    public AlgorithmCallbackController(AlgorithmService algorithmService) {
        this.algorithmService = algorithmService;
    }

    @PostMapping("/algorithm")
    @ApiOperation(value = "处理回调数据", notes = "接收回调的数据并将其传递给服务层进行处理")
    public ResponseEntity<String> handleAlgorithmCallback(@RequestBody AlgorithmCallbackRequest request) {
        // 调用业务层处理回调数据
        algorithmService.processAlgorithmCallback(request);

        // 返回成功响应
        return ResponseEntity.ok("Callback data processed successfully.");
    }
}

